//
//  ViewController.m
//  webview字符串加载内容
//
//  Created by h92 on 15/1/4.
//  Copyright (c) 2015年 李腾飞. All rights reserved.
//

#import "ViewController.h"
#define DeSheng @"http://m.dsmyk.cn/webindex.php?m=appjson&a=GetTypeJson&typeid=17554"

@interface ViewController ()

@end

@implementation ViewController
@synthesize strDeSheng;
@synthesize webView;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self startParse];
    [webView loadHTMLString:strDeSheng baseURL:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)startParse
{
    //string -url
    NSURL *url=[NSURL URLWithString:DeSheng];
    NSLog(@"%@",url);
    
    // url -request
    NSURLRequest *request=[[NSURLRequest alloc] initWithURL:url];
    // connect -data
    NSData *jsonData=[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    id jsonObj=[NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:nil];
    
    if (!jsonObj) {
        NSLog(@"解析失败");
    }
    
    int intTmp=(int)[jsonObj count];
    
    NSLog(@" 数组有%i组？",intTmp);
    NSDictionary *dictionaryData=[jsonObj objectAtIndex:intTmp-1];
    NSLog(@"%@",dictionaryData);
    
    strDeSheng=[dictionaryData objectForKey:@"description"];
    NSLog(@"%@",strDeSheng);
}

@end
